package io.renren.modules.communityService.service.impl;

import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import io.renren.common.utils.PageUtils;
import io.renren.common.utils.Query;

import io.renren.modules.communityService.dao.DbNoticeDao;
import io.renren.modules.communityService.entity.DbNoticeEntity;
import io.renren.modules.communityService.dto.DbNoticeDTO;
import io.renren.modules.communityService.vo.DbNoticeVO;
import io.renren.modules.communityService.service.DbNoticeService;
import io.renren.modules.communityService.conver.DbNoticeConver;

import java.io.Serializable;
import java.util.Collection;


@Service("dbNoticeService")
public class DbNoticeServiceImpl extends ServiceImpl<DbNoticeDao, DbNoticeEntity> implements DbNoticeService {

    @Override
    public PageUtils<DbNoticeVO> queryPage(DbNoticeDTO dbNotice) {
        IPage<DbNoticeEntity> page = baseMapper.selectPage(
                new Query<DbNoticeEntity>(dbNotice).getPage(),
                new QueryWrapper<DbNoticeEntity>()
        );

        return PageUtils.<DbNoticeVO>page(page).setList(DbNoticeConver.MAPPER.conver(page.getRecords()));
    }
    @Override
    public DbNoticeVO getById(Integer id) {
        return DbNoticeConver.MAPPER.conver(baseMapper.selectById(id));
    }

    @Override
    public boolean save(DbNoticeDTO dbNotice) {
        DbNoticeEntity dbNoticeEntity = DbNoticeConver.MAPPER.converDTO(dbNotice);
        return this.save(dbNoticeEntity);
    }

    @Override
    public boolean updateById(DbNoticeDTO dbNotice) {
        DbNoticeEntity dbNoticeEntity = DbNoticeConver.MAPPER.converDTO(dbNotice);
        return this.updateById(dbNoticeEntity);
    }

    @Override
    public boolean removeById(Serializable id) {
        return super.removeById(id);
    }

    @Override
    public boolean removeByIds(Collection<? extends Serializable> ids) {
        return super.removeByIds(ids);
    }

}
